<?php
include_once('common/header.php');
$intPlaceId		= $objRequest->getParam('placeid', 0);
$intAction		= $objRequest->getParam('act', 0);
$strContent		= $objRequest->getParam('content', '');

$intError		= 0;
if(!$intPlaceId) $intError = 23;
elseif(trim($strContent) == '' || !isset($strContent)) $intError = 1;
elseif(strlen($strContent) < 2) $intError = 2;

$objPlace 		= new Place();
if($intError == 0)
{
	$objView	= Zend_Registry::get('objView');
	$strData = '';
	if($intAction == 2) {
		
	}
	else if($intAction == 3)	
	{
		$intError = $objPlace->updateMap($AppUI->id, $intPlaceId, $strContent);
		if($intError == 0)
		{	
			$strMessage = $arrMessage[7];			
			$this->view->row = array('placeid' => $intPlaceId, 'map' => $strContent, 'userid' => $AppUI->id);			
			$strData	= $objView->fetch('place/box-map.tpl');
			$arrJson	= array('error'=>0, 'msg'=>$strMessage, 'data'=>$strData);
		}
		else
		{			
			$intError = 24;
		}
	}
	else if($intAction == 4) {
		$intError = $objPlace->updateContact($AppUI->id, $intPlaceId, $strContent);
		if($intError == 0)
		{	
			$strMessage = $arrMessage[9];			
			$this->view->row = array('placeid' => $intPlaceId, 'contact' => $strContent, 'userid' => $AppUI->id);			
			$strData	= $objView->fetch('place/box-contact.tpl');
			$arrJson	= array('error'=>0, 'msg'=>$strMessage, 'data'=>$strData);
		}
		else
		{			
			$intError = 26;
		}
	}	
	else if($intAction == 6) {
		$intError = $objPlace->updatePromotion($AppUI->id, $intPlaceId, $strContent);
		if($intError == 0)
		{	
			$strMessage = $arrMessage[8];			
			$this->view->row = array('placeid' => $intPlaceId, 'promotion' => $strContent, 'userid' => $AppUI->id);			
			$strData	= $objView->fetch('place/box-promotion.tpl');
			$arrJson	= array('error'=>0, 'msg'=>$strMessage, 'data'=>$strData);
		}
		else
		{			
			$intError = 25;
		}
	}
	if($intError == 0) {	
		echo Zend_Json::encode($arrJson);
		exit();
	}
}
if($intError > 0) {
	$arrJson 	= array('error'=>$intError,'msg'=>$arrError[$intError]);
	echo Zend_Json::encode($arrJson);
	exit();
}
?>
